<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我赞过的</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <header class="header header-shadow" id="doubleClick">
        <div class="header-left">
            <div tapmode onclick="comeBack();" class="nav-left"><img class="icon-back" src="../../icon/icon-back.png"/>
            </div>
        </div>
        <h2>我赞过的</h2>
    </header>
</div>

<div class="mescroll" id="mescroll" style="padding-top: 1.5rem;">
    <section class="html_section pr30 pl30 ">
        <ul class="userType_list3">
            <li tapmode class="on" data-id="1">新闻</li>
            <li tapmode data-id="2">帖子</li>
            <li tapmode data-id="4">评论</li>
            <li tapmode data-id="6">赛况</li>
        </ul>
        <div class="page_box on" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="index-news">
                <ul>

                </ul>
            </div>
            <div class="nodata"></div>
        </div>
        <div class="page_box" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="index-news user-dynamic">
                <ul>

                </ul>
            </div>
            <div class="nodata"></div>
        </div>
        <div class="page_box" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="person-comment">
                <ul class="pt20">

                </ul>
            </div>
            <div class="nodata"></div>
        </div>
        <div class="page_box" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="person-comment">
                <ul class="pt20">

                </ul>
            </div>
            <div class="nodata"></div>
        </div>
    </section>
</div>

</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/mescroll.min.css"/>
<script type="text/javascript" src="../../script/mescroll.min.js"></script>
<script type="text/javascript">
    var type = 1;
    apiready = function () {
        setFixStatusBar(); //设置状态栏
        pop.loading();
        keybackListener()

        //上拉加载
        pullUpLoading(function () {
            var ifpage = $(".page.on").data("ifpage");
            if (ifpage == true) {
                var page = Number($(".page.on").data("page"));
                $(".page.on").data("page", page++);
                ready();
            }
        });
        /*//下拉刷新
        dropDownRefresh(function () {
            $(".page_box.on").data('page', 1);
            $(".page_box.on").data('ifpage', true);
            ready();
        })*/
        var isOne = true;
        api.addEventListener({
            name: 'viewappear'
        }, function (ret, err) {
            if (isOne) {
                isOne = false;
                ready();
            }
        });
    }

    //创建MeScroll对象
    var mescroll = new MeScroll("mescroll", {
        down: {
            auto: false, //是否在初始化完毕之后自动执行下拉回调callback; 默认true
            callback: downCallback //下拉刷新的回调
        }
    });
    /*下拉刷新的回调 */
    function downCallback() {
        $(".page_box.on").data('page', 1);
        $(".page_box.on").data('ifpage', true);
        ready();

        //mescroll.endErr();
    }


    function ready() {
        page = $(".page_box.on").data("page");
        getAjax(Interface.get_fabulous_list, {token: $api.getStorage('token'), page: page, type: type}, function (res) {
            $(".page_box.on").data('ready', true);
            pop.close();
            var list = res.data.list;
            var html = '';
            $.each(list, function (i, item) {
                if (type == 1) {
                    var toUp = '';
                    var hotHtml = '';
                    if (isDefine(item)) {
                        if (item.recommend == 1) {
                            toUp = '<span class="bt-pd toUp">置顶</span>';
                        }
                        if (isDefine(item.news_label_name)) {
                            if (item.news_label_name.length >= 2) {
                                hotHtml = '<div class="detail-bottom">' +
                                    '              <div class="bottom-tips">' + toUp +
                                    '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[0].id + '})\'>#' + item.news_label_name[0].title + '#</span>' +
                                    '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[1].id + '})\'>#' + item.news_label_name[1].title + '#</span>' +
                                    '                  <span class="bt-pd time">' + item.date + '</span>' +
                                    '              </div>' +
                                    '              <div class="bottom-hot">' + item.hot_number + '</div>' +
                                    '          </div>';
                            } else if (item.news_label_name.length == 1) {
                                hotHtml = '<div class="detail-bottom">' +
                                    '              <div class="bottom-tips">' + toUp +
                                    '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[0].id + '})\'>#' + item.news_label_name[0].title + '#</span>' +
                                    '                  <span class="bt-pd time">' + item.date + '</span>' +
                                    '              </div>' +
                                    '              <div class="bottom-hot">' + item.hot_number + '</div>' +
                                    '          </div>';
                            }

                        } else {
                            hotHtml = '<div class="detail-bottom">' +
                                '              <div class="bottom-tips">' + toUp +
                                '                  <span class="bt-pd time">' + item.date + '</span>' +
                                '              </div>' +
                                '              <div class="bottom-hot">' + item.hot_number + '</div>' +
                                '          </div>';
                        }
                    }

                    var param = {"news_id": item.id}

                    //标题，文字，图片
                    var titleHtml = '';
                    if (isDefine(item.void_ids)) {
                        //视频新闻
                        titleHtml = '<div class="video-detail">' +
                            '             <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                            '             <div class="video-box bg-cover" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\' style="background-image: url(' + ajaxUrl + item.void_icon_path + ')";>' +
                            '                 <p class="single-ellipsis"></p>' +
                            '                 <span class="icon-play"></span>' +
                            '                 <span class="time"></span>' +
                            '              </div>' + hotHtml +
                            '         </div>';

                    } else {
                        //三张图片新闻
                        if (isDefine(item.icon_path)) {
                            if (item.icon_path.length >= 3) {
                                titleHtml = '<div class="video-detail">' +
                                    '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                                    '            <div class="detail-img-list" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[0] + ');"></div>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[1] + ');"></div>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[2] + ');"></div>' +
                                    '            </div>' + hotHtml +
                                    '        </div>'
                            } else if (item.icon_path.length == 2) {
                                //两张图片新闻
                                titleHtml = '<div class="video-detail">' +
                                    '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                                    '            <div class="detail-img-list two-img" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[0] + ');"></div>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[1] + ');"></div>' +
                                    '            </div>' + hotHtml +
                                    '        </div>'
                            } else if (item.icon_path.length == 1) {

                                if (item.recommend == 1) {
                                    toUp = '<span class="bt-pd toUp">置顶</span>';
                                }
                                if (isDefine(item.news_label_name)) {
                                    if (item.news_label_name.length >= 1) {
                                        hotHtml = '<div class="detail-bottom">' +
                                            '              <div class="bottom-tips">' + toUp +
                                            '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[0].id + '})\'>#' + item.news_label_name[0].title + '#</span>' +
                                            '                  <span class="bt-pd time">' + item.date + '</span>' +
                                            '              </div>' +
                                            '              <div class="bottom-hot">' + item.hot_number + '</div>' +
                                            '          </div>';
                                    }

                                }
                                //单张图片新闻
                                titleHtml = '<div class="single-news">' +
                                    '             <div class="detail-img-list" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                    '                 <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[0] + ');"></div>' +
                                    '             </div>' +
                                    '             <div class="video-detail">' +
                                    '                 <h6 class="news-title multiline-ellipsis_3" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' + hotHtml +
                                   /* '                 <p class="detail-info multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.brief + '</p>' + hotHtml +*/
                                    '             </div>' +
                                    '         </div>';
                            }
                        }else {
                            //无图
                            titleHtml = '<div class="video-detail">' +
                                '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                                '            </div>' + hotHtml +
                                '        </div>'

                        }


                    }

                    html += '<li>' + titleHtml + '</li>'
                } else if (type == 2) {
                    html += tiesList(item);
                } else if (type == 4) {
                    html += GetLikeList(item, 2);
                }else if(type == 6){
                    var toUp = '';
                    var hotHtml = '';
                    if (isDefine(item)) {
                        if (item.recommend == 1) {
                            toUp = '<span class="bt-pd toUp">置顶</span>';
                        }
                        if (isDefine(item.news_label_name)) {
                            if (item.news_label_name.length >= 2) {
                                hotHtml = '<div class="detail-bottom">' +
                                    '              <div class="bottom-tips">' + toUp +
                                    '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[0].id + '})\'>#' + item.news_label_name[0].title + '#</span>' +
                                    '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[1].id + '})\'>#' + item.news_label_name[1].title + '#</span>' +
                                    '                  <span class="bt-pd time">' + item.date + '</span>' +
                                    '              </div>' +
                                    '              <div class="bottom-hot">' + item.hot_number + '</div>' +
                                    '          </div>';
                            } else if (item.news_label_name.length == 1) {
                                hotHtml = '<div class="detail-bottom">' +
                                    '              <div class="bottom-tips">' + toUp +
                                    '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[0].id + '})\'>#' + item.news_label_name[0].title + '#</span>' +
                                    '                  <span class="bt-pd time">' + item.date + '</span>' +
                                    '              </div>' +
                                    '              <div class="bottom-hot">' + item.hot_number + '</div>' +
                                    '          </div>';
                            }

                        } else {
                            hotHtml = '<div class="detail-bottom">' +
                                '              <div class="bottom-tips">' + toUp +
                                '                  <span class="bt-pd time">' + item.date + '</span>' +
                                '              </div>' +
                                '              <div class="bottom-hot">' + item.hot_number + '</div>' +
                                '          </div>';
                        }
                    }
                    var param = {"war_id": item.id}
                    //标题，文字，图片
                    var titleHtml = '';
                    //三张图片新闻
                    if (isDefine(item.icon_path)) {
                        if (item.icon_path.length >= 3) {
                            titleHtml = '<div class="video-detail">' +
                                '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                                '            <div class="detail-img-list" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' +
                                '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[0] + ');"></div>' +
                                '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[1] + ');"></div>' +
                                '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[2] + ');"></div>' +
                                '            </div>' + hotHtml +
                                '        </div>'
                        } else if (item.icon_path.length == 2) {
                            //两张图片新闻
                            titleHtml = '<div class="video-detail">' +
                                '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                                '            <div class="detail-img-list two-img" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' +
                                '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[0] + ');"></div>' +
                                '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[1] + ');"></div>' +
                                '            </div>' + hotHtml +
                                '        </div>'
                        } else if (item.icon_path.length == 1) {

                            if (item.recommend == 1) {
                                toUp = '<span class="bt-pd toUp">置顶</span>';
                            }
                            if (isDefine(item.news_label_name)) {
                                if (item.news_label_name.length >= 1) {
                                    hotHtml = '<div class="detail-bottom">' +
                                        '              <div class="bottom-tips">' + toUp +
                                        '                  <span class="bt-pd tips" onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + '})\'>#' + item.news_label_name[0].title + '#</span>' +
                                        '                  <span class="bt-pd time">' + item.date + '</span>' +
                                        '              </div>' +
                                        '              <div class="bottom-hot">' + item.hot_number + '</div>' +
                                        '          </div>';
                                }

                            }
                            //单张图片新闻
                            titleHtml = '<div class="single-news">' +
                                '             <div class="detail-img-list" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                '                 <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[0] + ');"></div>' +
                                '             </div>' +
                                '             <div class="video-detail">' +
                                '                 <h6 class="news-title multiline-ellipsis_3" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' + hotHtml +
                             /*   '                 <p class="detail-info multiline-ellipsis" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'></p>' + hotHtml +*/
                                '             </div>' +
                                '         </div>';
                        }
                    }
                    html += '<li>' + titleHtml + '</li>'
                }
            })
            // console.log(html)

            pop.close();
            if (page == 1){
                // console.log(html)
                $(".page_box.on ul").html(html);
            } else {
                $(".page_box.on ul").append(html);
            }
            if (list.length < res.data.sumpage) {
                $(".page_box.on").data('ifpage', false);
                $(".page_box.on .nodata").show();
            } else {
                $(".page_box.on .nodata").hide();
            }
            if (list.length == 0) {
                if (page == 1) {
                    $(".page_box.on .nodata").hide();
                    $(".page_box.on ul").html(noData);
                }
            }
            mescroll.endErr()
        }, function (res, err) {
            mescroll.endErr()
            pop.close();
        })
    }

    $(".userType_list3 li").click(function () {
        $(".userType_list3 li").removeClass("on");
        $(this).addClass("on");
        $(".page_box").removeClass("on");
        $(".page_box").eq($(this).index()).addClass("on");
        type = $(this).data("id");
        var ifr = $(".page_box.on").data('ready');
        if (ifr == false) {
            ready();
        }
    })

    //评论
    function GetLikeList(item, type) {
        var html = '';
        if (!isDefine(item)) {
            return true;
        }
        // console.log(jsonChange(item));
        var userInfo = $api.getStorage('userInfo');
        var userData = item.member;
        var badgeList = '';//徽章列表
        if (isDefine(userData.badge_path)) {
            for (var k = 0; k < userData.badge_path.length; k++) {
                if (k <= 5) {
                    badgeList += '<dd class="icon"><img src="' + getImg(userData.badge_path[k]) + '" alt=""></dd>'
                }
            }
        }
        var userVip = '';
        if(isDefine(userData.attestation_status)){
            if(userData.attestation_status == 2){
                userVip = '<span class="vip"></span>';
            }
        }
        var member_id = {'member_id': userData.id};
        html += '<li>';
        html += '<div class="common-user-detail">';
        html += '<div class="user-info"tapmode onclick=\'commonUrl("../activity/person_index",' + jsonChange(member_id) + ')\'>';
        html += '<div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + getImg(userData.icon_path) + ');"></div>'+userVip+'</div>';
        html += '<div class="info">';
        html += '<div class="name">';
        html += '<h6>' + userData.name + '</h6>';
        html += '<dl class="badge-list" tapmode onclick="toBadgePage(event)">';
        html += badgeList;
        html += '</dl>';
        html += '</div>';
        html += '<span class="time">' + item.date + '</span>';
        html += '</div>';
        html += '</div>';
        if (userInfo.id != userData.id) {
            if (item.member_follow) {
                html += '<div class="follow" tapmode onclick="followAction(1,' + userData.id + ')">';
                html += '<span class="followed">已关注</span>';
                html += '</div>';
            } else {
                html += '<div class="follow" tapmode onclick="followAction(2,' + userData.id + ')">';
                html += '<span class="no-follow">关注</span>';
                html += '</div>';
            }
        }
        html += '</div>';
        var result = getDataType(item);
        if (type == 2) {
            html += '<div class="comment-detail multiline-ellipsis_3"  style="-webkit-line-clamp: initial;" onclick=\'commonUrl("../activity/person_index",' + jsonChange(member_id) + ')\'>';
            html += '<p>' + item.comment + '</p>';
            html += '</div>';
        }
        html += '<div class="invitation-div" tapmode  onclick=\'commonUrl("' + result.url + '",' + jsonChange(result.urlParam) + ')\'>';
        html += '<div class="invite-icon bg-cover" style="background: url(' + getImg(item.content_path) + ')"></div>';
        html += '<div class="invite-info">';
        html += '<h6 class="single-ellipsis"><span>' + result.text + '</span>' + item.title + '</h6>';
        if (item.type != 1)
            html += '<p>来自' + item.circle_title + '</p>';
        html += '</div>';
        html += '</div>';
        html += '<div class="c-999 flex_end f24 mt10">'+item.fabulous_date+'</div>';

        html += '</li>';
        return html;
    }

    function getDataType(item) {
        var result = '帖子';
        var url = '../circle/invite_detail';
        var urlParam = {'invitation_id': item.article_id};
        switch (item.type) {
            case 1:
                result = '新闻';
                url = '../index/news_detail';
                urlParam = {'news_id': item.article_id};
                break;
            case 2:
                result = '帖子';
                url = '../circle/invite_detail';
                urlParam = {'invitation_id': item.article_id};
                break;
            case 3:
                result = '活动';
                url = '../activity/activity_index';
                urlParam = {"activity_id": item.article_id};
                break;

        }
        return {
            text: result,
            url: url,
            urlParam: urlParam
        }
    }

</script>
